home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5338 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: news2.ios.com!usenet
  2. From: vlad@gramercy.ios.com (Vlastimil Adamovsky)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: C++ Gurus! Is it correct?
  5. Date: Sat, 03 Feb 1996 22:32:48 GMT
  6. Organization: Internet Online Services
  7. Message-ID: <4f0n8s$a3b@news2.ios.com>
  8. References: <4eqvtg$cg5@israel-info.datasrv.co.il> <4etnju$6gn@rolaids.frco.com>
  9. NNTP-Posting-Host: ppp-47.ts-7.hck.idt.net
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. Jadam@tcmail.frco.com (Jim Adam) wrote:
  13.  
  14. >In article <4eqvtg$cg5@israel-info.datasrv.co.il>, dmitry@enigma.co.il 
  15. >says...
  16.  
  17. >>Is next code is correct from point of view of pure C++ ?
  18.  
  19. >>class A
  20. >>{
  21. >>};
  22.  
  23. >>class B
  24. >>{
  25. >>};
  26.  
  27. >>class C : public A, public B
  28. >>{
  29. >>};
  30.  
  31. >>A* pA = new C;
  32. >>B* pB = new C;
  33.  
  34. >>delete pA;
  35. >>delete pB;
  36.  
  37. >==========================
  38.  
  39. >This is correct.  However, to ensure the destructor for class
  40. >C gets called correctly, class A and B both need virtual 
  41. >destructors.
  42.  
  43. >E.g., 
  44.  
  45. >  class A
  46. >  {
  47. >    public:
  48. >      virtual ~A();
  49. >  };
  50.  
  51. >And likewise for class B.   
  52.  
  53. >Jim
  54.  
  55. I don't think the virtual destructor is necessary in this specific
  56. case where you have no added data in subclasses. 
  57.  
  58.  
  59.  
  60. *******************************************
  61. *    Vlastimil Adamovsky                  *
  62. * Smalltalk, C++ and Envelop development  *
  63. *******************************************
  64.  
  65.